package RefactoringA1.src;

/**
 * #Refactor complete.
 * @author christopher.witcher
 *
 */
public class CreditCard 
{
	/**Field was removed because it is never used.
	 *  
	 */
	//private static int fLastCreditCardNumber;
	
	/**
	 * These fields are never used and should be eliminated.
	 * 
	 * #Refactored
	 private int fAccountConnectedTo;*/
	private int fCreditCardNumber;
	
	/**
	 * These fields should be replaced by the CustomerData Class
	 
	private String fName;
	private String fStreet;
	private String fTown;
	private String fzipCode;
	private String fCountry;
	*/
	CustomerData customer = null;
	
	
	private double fLimit; // you cannot spend more than this limit
	private double fBalance;
	
	/**
	 * These constructors can be combined into one constructor.
	 * @param name
	 * @param street
	 * @param town
	 * @param zipCode
	 * @param country
	 * @param balance
	 */
	public CreditCard(String name, String street, String town, String zipCode, String country, double balance)
	{
		customer = new CustomerData(name, street, zipCode, town, country, this.fCreditCardNumber);
		fLimit = balance <= 2500 ? 2500 : 5000;
		fBalance = 0;
	}
	
	/**
	 * This method has multiple return statements and should be changed to one.
	 * @param amount
	 * @return
	 */
	public boolean pay(double amount)
	{
		boolean output = false;
		if((fBalance - amount) < -fLimit)
		{
			fBalance -= amount;
			output = true;
		}
		
		
		return output;
	}
	
	/**
	 * Method added to return the Customer
	 * @return
	 */
	public CustomerData getCustomer() {
		return this.customer;
	}

	public void setfCreditCardNumber(int newCreditCardNumber) {
		this.fCreditCardNumber = newCreditCardNumber;
	}
	
	public int getCreditCard(){
		return this.fCreditCardNumber;
	}
}
